{% extends 'base.html' %}

{% block title %}{{ consumable.name }} - 耗材记录管理 - 固定资产管理系统{% endblock %}

{% block extra_css %}
<style>
    /* 操作类型徽章样式 */
    .transaction-badge {
        font-size: 0.85rem;
        padding: 0.5rem 0.8rem;
        border-radius: 0.6rem;
        font-weight: 700;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
        border: 2px solid transparent;
        display: inline-flex;
        align-items: center;
        gap: 0.3rem;
    }

    .transaction-in {
        background: linear-gradient(135deg, #198754, #20c997);
        color: #ffffff;
        border-color: #146c43;
        box-shadow: 0 3px 6px rgba(25, 135, 84, 0.4);
    }

    .transaction-out {
        background: linear-gradient(135deg, #dc3545, #e85d75);
        color: #ffffff;
        border-color: #b02a37;
        box-shadow: 0 3px 6px rgba(220, 53, 69, 0.4);
    }

    .transaction-adjust {
        background: linear-gradient(135deg, #0dcaf0, #6f42c1);
        color: #ffffff;
        border-color: #0aa2c0;
        box-shadow: 0 3px 6px rgba(13, 202, 240, 0.4);
    }
</style>
{% endblock %}

{% block content %}
<div class="row">
    <div class="col-md-12">
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="{% url 'assets:index' %}">首页</a></li>
                <li class="breadcrumb-item"><a href="{% url 'assets:consumable_list' %}">耗材管理</a></li>
                <li class="breadcrumb-item active" aria-current="page">{{ consumable.name }}</li>
            </ol>
        </nav>

        <div class="d-flex justify-content-between align-items-center mb-3">
            <h2><i class="fas fa-box me-2"></i>{{ consumable.name }} - 耗材记录管理</h2>
            <div class="btn-group">
                <button type="button" class="btn btn-success" data-bs-toggle="modal" data-bs-target="#stockInModal">
                    <i class="fas fa-arrow-down me-1"></i>入库
                </button>
                <button type="button" class="btn btn-warning" data-bs-toggle="modal" data-bs-target="#stockOutModal">
                    <i class="fas fa-arrow-up me-1"></i>出库
                </button>
                <a href="{% url 'assets:consumable_update' consumable.pk %}" class="btn btn-primary">
                    <i class="fas fa-edit me-1"></i>编辑
                </a>
                <button type="button" class="btn btn-outline-primary dropdown-toggle dropdown-toggle-split"
                    data-bs-toggle="dropdown">
                    <span class="visually-hidden">更多操作</span>
                </button>
                <ul class="dropdown-menu">
                    <li><a class="dropdown-item" href="#" onclick="exportRecords()">
                            <i class="fas fa-download me-2"></i>导出记录
                        </a></li>
                    <li><a class="dropdown-item"
                            href="{% url 'assets:inventory_log_list' %}?search={{ consumable.name }}">
                            <i class="fas fa-history me-2"></i>查看全部记录
                        </a></li>
                    <li><a class="dropdown-item" href="#" onclick="printLabel()">
                            <i class="fas fa-print me-2"></i>打印标签
                        </a></li>
                    <li>
                        <hr class="dropdown-divider">
                    </li>
                    <li><a class="dropdown-item" href="{% url 'assets:consumable_list' %}">
                            <i class="fas fa-arrow-left me-2"></i>返回列表
                        </a></li>
                    <li>
                        <hr class="dropdown-divider">
                    </li>
                    <li><a class="dropdown-item text-danger" href="{% url 'assets:consumable_delete' consumable.pk %}"
                            onclick="return confirm('确定要删除耗材 {{ consumable.name }} 吗？')">
                            <i class="fas fa-trash me-2"></i>删除耗材
                        </a></li>
                </ul>
            </div>
        </div>

        <div class="row">
            <!-- 基本信息 -->
            <div class="col-md-8">
                <!-- 耗材基本信息 -->
                <div class="card mb-4">
                    <div class="card-header">
                        <h5 class="mb-0">
                            <i class="fas fa-info-circle me-2"></i>耗材基本信息
                        </h5>
                    </div>
                    <div class="card-body">
                        <div class="row">
                            <div class="col-md-6">
                                <table class="table table-borderless">
                                    <tr>
                                        <td width="30%" class="text-muted">耗材名称:</td>
                                        <td><strong>{{ consumable.name }}</strong></td>
                                    </tr>
                                    <tr>
                                        <td class="text-muted">耗材编码:</td>
                                        <td><code>{{ consumable.code }}</code></td>
                                    </tr>
                                    <tr>
                                        <td class="text-muted">型号规格:</td>
                                        <td>
                                            {% if consumable.model %}
                                            <span class="badge bg-secondary">{{ consumable.model }}</span>
                                            {% else %}
                                            <span class="text-muted">-</span>
                                            {% endif %}
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="text-muted">类别:</td>
                                        <td>
                                            {% if consumable.category %}
                                            <span class="badge bg-info">{{ consumable.category.name }}</span>
                                            {% else %}
                                            <span class="text-muted">-</span>
                                            {% endif %}
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="text-muted">计量单位:</td>
                                        <td><span class="badge bg-light text-dark">{{ consumable.unit }}</span></td>
                                    </tr>
                                </table>
                            </div>
                            <div class="col-md-6">
                                <table class="table table-borderless">
                                    <tr>
                                        <td width="30%" class="text-muted">存储仓库:</td>
                                        <td>
                                            {% if consumable.warehouse %}
                                            <div class="d-flex align-items-center">
                                                <i class="fas fa-warehouse me-1 text-success"></i>
                                                <a href="{% url 'assets:warehouse_detail' consumable.warehouse.pk %}"
                                                    class="text-decoration-none">{{ consumable.warehouse.name }}</a>
                                            </div>
                                            {% else %}
                                            <span class="text-muted">-</span>
                                            {% endif %}
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="text-muted">存储位置:</td>
                                        <td>
                                            {% if consumable.location %}
                                            <i class="fas fa-map-marker-alt me-1 text-info"></i>{{ consumable.location }}
                                            {% else %}
                                            <span class="text-muted">-</span>
                                            {% endif %}
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="text-muted">采购单价:</td>
                                        <td>
                                            <span class="text-success fw-bold">¥{{ consumable.purchase_price|floatformat:2 }}</span>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="text-muted">供应商:</td>
                                        <td>
                                            {% if consumable.supplier %}
                                            <div class="d-flex align-items-center">
                                                <i class="fas fa-truck me-1 text-info"></i>
                                                <a href="{% url 'assets:supplier_detail' consumable.supplier.pk %}"
                                                    class="text-decoration-none">{{ consumable.supplier.name }}</a>
                                            </div>
                                            {% else %}
                                            <span class="text-muted">-</span>
                                            {% endif %}
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="text-muted">创建时间:</td>
                                        <td>
                                            <i class="fas fa-calendar-plus me-1 text-primary"></i>{{ consumable.created_at|date:"Y-m-d H:i" }}
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </div>

                        {% if consumable.description %}
                        <div class="mt-3">
                            <h6 class="text-muted">
                                <i class="fas fa-file-alt me-2"></i>耗材描述:
                            </h6>
                            <div class="alert alert-light">
                                <p class="mb-0">{{ consumable.description }}</p>
                            </div>
                        </div>
                        {% endif %}
                    </div>
                </div>

                <!-- 库存状态实时展示 -->
                <div class="card mb-4">
                    <div class="card-header">
                        <h5 class="mb-0">
                            <i class="fas fa-chart-line me-2"></i>库存状态实时展示
                        </h5>
                    </div>
                    <div class="card-body">
                        <div class="row">
                            <div class="col-md-6">
                                <table class="table table-borderless">
                                    <tr>
                                        <td width="30%" class="text-muted">当前库存:</td>
                                        <td>
                                            {% if consumable.quantity <= 0 %}
                                                <span class="badge bg-dark fs-6">{{ consumable.quantity }} {{ consumable.unit }}</span>
                                                <small class="text-dark ms-2">缺货</small>
                                            {% elif consumable.quantity <= consumable.min_quantity %}
                                                <span class="badge bg-danger fs-6">{{ consumable.quantity }} {{ consumable.unit }}</span>
                                                <small class="text-danger ms-2">库存不足</small>
                                            {% else %}
                                                <span class="badge bg-success fs-6">{{ consumable.quantity }} {{ consumable.unit }}</span>
                                                <small class="text-success ms-2">库存正常</small>
                                            {% endif %}
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="text-muted">最低库存:</td>
                                        <td>
                                            <span class="text-info fw-bold">{{ consumable.min_quantity }} {{ consumable.unit }}</span>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="text-muted">库存价值:</td>
                                        <td>
                                            {% widthratio consumable.quantity 1 consumable.purchase_price as stock_value %}
                                            <span class="text-success fw-bold">¥{{ stock_value|floatformat:2 }}</span>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                            <div class="col-md-6">
                                <table class="table table-borderless">
                                    <tr>
                                        <td width="30%" class="text-muted">库存周转:</td>
                                        <td>
                                            {% if month_out_quantity > 0 %}
                                            <span class="text-primary fw-bold">{{ month_out_quantity }} {{ consumable.unit }}</span>
                                            <small class="text-muted ms-1">(本月)</small>
                                            {% else %}
                                            <span class="text-muted">暂无数据</span>
                                            {% endif %}
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="text-muted">最后入库:</td>
                                        <td>
                                            {% if last_in_log %}
                                            <i class="fas fa-arrow-down me-1 text-success"></i>{{ last_in_log.created_at|date:"Y-m-d H:i" }}
                                            {% else %}
                                            <span class="text-muted">暂无记录</span>
                                            {% endif %}
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="text-muted">最后出库:</td>
                                        <td>
                                            {% if last_out_log %}
                                            <i class="fas fa-arrow-up me-1 text-danger"></i>{{ last_out_log.created_at|date:"Y-m-d H:i" }}
                                            {% else %}
                                            <span class="text-muted">暂无记录</span>
                                            {% endif %}
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </div>

                        <!-- 库存状态进度条 -->
                        <div class="mt-3">
                            <h6 class="text-muted mb-2">库存状态指示</h6>
                            {% if consumable.min_quantity > 0 %}
                            {% widthratio consumable.quantity 1 consumable.min_quantity as stock_ratio %}
                            {% widthratio stock_ratio 1 100 as stock_percentage %}
                            <div class="progress mb-2" style="height: 25px;">
                                {% if consumable.quantity <= 0 %}
                                    <div class="progress-bar bg-dark" role="progressbar" style="width: 5%">
                                        缺货
                                    </div>
                                {% elif stock_percentage <= 100 %}
                                    <div class="progress-bar bg-danger" role="progressbar" style="width: {{ stock_percentage }}%">
                                        {{ stock_percentage|floatformat:0 }}%
                                    </div>
                                {% elif stock_percentage <= 150 %}
                                    <div class="progress-bar bg-warning" role="progressbar" style="width: 100%">
                                        库存偏低
                                    </div>
                                {% else %}
                                    <div class="progress-bar bg-success" role="progressbar" style="width: 100%">
                                        库存充足
                                    </div>
                                {% endif %}
                </div>
                <div class="d-flex justify-content-between">
                    <small class="text-muted">0</small>
                    <small class="text-muted">最低库存线: {{ consumable.min_quantity }}</small>
                    <small class="text-muted">当前: {{ consumable.quantity }}</small>
                </div>
                {% endif %}
            </div>
        </div>
    </div>
</div>

<!-- 侧边栏信息 -->
<div class="col-md-4">
    <!-- 库存状态概览 -->
    <div class="card mb-4">
        <div class="card-header">
            <h5 class="mb-0">
                <i class="fas fa-chart-pie me-2"></i>库存状态概览
            </h5>
        </div>
        <div class="card-body text-center">
            <div class="mb-3">
                {% if consumable.quantity <= 0 %}
                    <div class="alert alert-dark">
                        <i class="fas fa-exclamation-triangle fa-2x mb-2"></i>
                        <h5>缺货警告</h5>
                        <p class="mb-0">当前库存为0，需要紧急补货</p>
                    </div>
                {% elif consumable.quantity <= consumable.min_quantity %}
                    <div class="alert alert-danger">
                        <i class="fas fa-exclamation-triangle fa-2x mb-2"></i>
                        <h5>库存不足</h5>
                        <p class="mb-0">当前库存低于最低库存线</p>
                    </div>
                {% else %}
                    <div class="alert alert-success">
                        <i class="fas fa-check-circle fa-2x mb-2"></i>
                        <h5>库存正常</h5>
                        <p class="mb-0">当前库存充足</p>
                    </div>
                {% endif %}
    </div>

    <div class="row text-center">
        <div class="col-6">
            <h4 class="text-primary">{{ consumable.quantity }}</h4>
            <small class="text-muted">当前库存</small>
        </div>
        <div class="col-6">
            <h4 class="text-info">{{ consumable.min_quantity }}</h4>
            <small class="text-muted">最低库存</small>
        </div>
    </div>
</div>
</div>

<!-- 快速操作 -->
<div class="card mb-4">
    <div class="card-header">
        <h5 class="mb-0">
            <i class="fas fa-bolt me-2"></i>快速操作
        </h5>
    </div>
    <div class="card-body">
        <div class="d-grid gap-2">
            <button type="button" class="btn btn-success" data-bs-toggle="modal" data-bs-target="#stockInModal">
                <i class="fas fa-arrow-down me-2"></i>入库操作
            </button>
            <button type="button" class="btn btn-warning" data-bs-toggle="modal" data-bs-target="#stockOutModal">
                <i class="fas fa-arrow-up me-2"></i>出库操作
            </button>
            <hr class="my-2">
            <a href="{% url 'assets:consumable_update' consumable.pk %}" class="btn btn-outline-primary btn-sm">
                <i class="fas fa-edit me-2"></i>编辑信息
            </a>
            <button type="button" class="btn btn-outline-info btn-sm" onclick="exportRecords()">
                <i class="fas fa-download me-2"></i>导出记录
            </button>
            <button type="button" class="btn btn-outline-secondary btn-sm" onclick="printLabel()">
                <i class="fas fa-print me-2"></i>打印标签
            </button>
        </div>
    </div>
</div>

<!-- 统计信息 -->
<div class="card">
    <div class="card-header">
        <h5 class="mb-0">
            <i class="fas fa-chart-bar me-2"></i>统计信息
        </h5>
    </div>
    <div class="card-body">
        <table class="table table-borderless table-sm">
            <tr>
                <td class="text-muted">总入库次数:</td>
                <td>
                    <span class="text-success fw-bold">{{ total_in_count|default:0 }}</span>
                </td>
            </tr>
            <tr>
                <td class="text-muted">总出库次数:</td>
                <td>
                    <span class="text-danger fw-bold">{{ total_out_count|default:0 }}</span>
                </td>
            </tr>
            <tr>
                <td class="text-muted">本月入库:</td>
                <td>
                    <span class="text-success">{{ month_in_quantity|default:0 }} {{ consumable.unit }}</span>
                </td>
            </tr>
            <tr>
                <td class="text-muted">本月出库:</td>
                <td>
                    <span class="text-danger">{{ month_out_quantity|default:0 }} {{ consumable.unit }}</span>
                </td>
            </tr>
            <tr>
                <td class="text-muted">库存周转率:</td>
                <td>
                    {% if turnover_rate %}
                    <span class="text-info fw-bold">{{ turnover_rate|floatformat:1 }}%</span>
                    {% else %}
                    <span class="text-muted">-</span>
                    {% endif %}
                </td>
            </tr>
        </table>
    </div>
</div>
</div>
</div>

<!-- 入库/出库记录管理 -->
<div class="card mb-4">
    <div class="card-header d-flex justify-content-between align-items-center">
        <h5 class="mb-0">
            <i class="fas fa-history me-2"></i>入库/出库记录管理
        </h5>
        <div class="btn-group btn-group-sm">
            <button type="button" class="btn btn-outline-success" data-bs-toggle="modal" data-bs-target="#stockInModal">
                <i class="fas fa-arrow-down me-1"></i>入库
            </button>
            <button type="button" class="btn btn-outline-warning" data-bs-toggle="modal"
                data-bs-target="#stockOutModal">
                <i class="fas fa-arrow-up me-1"></i>出库
            </button>
            <a href="{% url 'assets:inventory_log_list' %}?search={{ consumable.name }}"
                class="btn btn-outline-primary">
                查看全部记录
            </a>
        </div>
    </div>
    <div class="card-body">
        {% if recent_logs %}
        <div class="table-responsive">
            <table class="table table-sm">
                <thead class="table-light">
                    <tr>
                        <th width="12%">操作类型</th>
                        <th width="15%">数量变化</th>
                        <th width="12%">操作人</th>
                        <th width="25%">操作描述</th>
                        <th width="15%">操作时间</th>
                        <th width="12%">库存余额</th>
                        <th width="9%">操作</th>
                    </tr>
                </thead>
                <tbody>
                    {% for log in recent_logs %}
                    <tr>
                        <td>
                            {% if log.transaction_type == "in" %}
                            <span class="badge bg-success">
                                <i class="fas fa-arrow-down me-1"></i>入库
                            </span>
                            {% elif log.transaction_type == "out" %}
                            <span class="badge bg-danger">
                                <i class="fas fa-arrow-up me-1"></i>出库
                            </span>
                            {% else %}
                            <span class="badge bg-info">
                                <i class="fas fa-exchange-alt me-1"></i>调整
                            </span>
                            {% endif %}
                        </td>
                        <td>
                            <div class="d-flex align-items-center">
                                {% if log.transaction_type == "in" %}
                                <span class="text-success fw-bold">+{{ log.quantity }}</span>
                                {% elif log.transaction_type == "out" %}
                                <span class="text-danger fw-bold">-{{ log.quantity }}</span>
                                {% else %}
                                <span class="text-info fw-bold">{{ log.quantity }}</span>
                                {% endif %}
                                <small class="text-muted ms-1">{{ consumable.unit }}</small>
                            </div>
                        </td>
                        <td>
                            {% if log.operator %}
                            <div class="d-flex align-items-center">
                                <i class="fas fa-user me-1 text-info"></i>
                                {{ log.operator.get_full_name|default:log.operator.username }}
                            </div>
                            {% else %}
                            <span class="text-muted">
                                <i class="fas fa-robot me-1"></i>系统
                            </span>
                            {% endif %}
                        </td>
                        <td>
                            {% if log.description %}
                            <span title="{{ log.description }}">{{ log.description|truncatechars:35 }}</span>
                            {% else %}
                            <span class="text-muted">-</span>
                            {% endif %}
                        </td>
                        <td>
                            <div class="text-nowrap">
                                <i class="fas fa-clock me-1 text-muted"></i>
                                {{ log.created_at|date:"Y-m-d H:i" }}
                            </div>
                        </td>
                        <td>
                            <span class="badge bg-light text-dark">{{ log.remaining_quantity|default:"-" }}</span>
                        </td>
                        <td>
                            <div class="btn-group btn-group-sm">
                                <button type="button" class="btn btn-outline-info" title="查看详情"
                                    onclick="showLogDetail({{ log.pk }})">
                                    <i class="fas fa-eye"></i>
                                </button>
                                {% if log.operator == request.user %}
                                <button type="button" class="btn btn-outline-danger" title="删除记录"
                                    onclick="deleteLog({{ log.pk }})">
                                    <i class="fas fa-trash"></i>
                                </button>
                                {% endif %}
                            </div>
                        </td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>

        <!-- 记录统计 -->
        <div class="mt-3">
            <div class="row text-center">
                <div class="col-md-3">
                    <div class="card bg-light">
                        <div class="card-body py-2">
                            <h6 class="text-success mb-0">{{ total_in_quantity|default:0 }}</h6>
                            <small class="text-muted">总入库量</small>
                        </div>
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="card bg-light">
                        <div class="card-body py-2">
                            <h6 class="text-danger mb-0">{{ total_out_quantity|default:0 }}</h6>
                            <small class="text-muted">总出库量</small>
                        </div>
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="card bg-light">
                        <div class="card-body py-2">
                            <h6 class="text-primary mb-0">{{ total_in_count|default:0 }}</h6>
                            <small class="text-muted">入库次数</small>
                        </div>
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="card bg-light">
                        <div class="card-body py-2">
                            <h6 class="text-warning mb-0">{{ total_out_count|default:0 }}</h6>
                            <small class="text-muted">出库次数</small>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        {% else %}
        <div class="text-center py-4">
            <i class="fas fa-inbox fa-3x text-muted mb-3"></i>
            <h5 class="text-muted">暂无库存记录</h5>
            <p class="text-muted">还没有任何入库或出库记录</p>
            <button type="button" class="btn btn-success" data-bs-toggle="modal" data-bs-target="#stockInModal">
                <i class="fas fa-arrow-down me-1"></i>创建首次入库记录
            </button>
        </div>
        {% endif %}
    </div>
</div>
</div>
</div>

<!-- 入库模态框 -->
<div class="modal fade" id="stockInModal" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">
                    <i class="fas fa-arrow-down me-2"></i>耗材入库
                </h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
            </div>
            <form method="post" action="{% url 'assets:consumable_detail' consumable.pk %}">
                {% csrf_token %}
                <input type="hidden" name="action" value="stock_in">
                <div class="modal-body">
                    <div class="mb-3">
                        <label class="form-label">入库数量</label>
                        <input type="number" class="form-control" name="quantity" step="0.01" min="0.01" required>
                        <div class="form-text">单位: {{ consumable.unit }}</div>
                    </div>
                    <div class="mb-3">
                        <label class="form-label">入库说明</label>
                        <textarea class="form-control" name="description" rows="3"
                            placeholder="请输入入库原因或说明..."></textarea>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                    <button type="submit" class="btn btn-success">
                        <i class="fas fa-check me-1"></i>确认入库
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>

<!-- 出库模态框 -->
<div class="modal fade" id="stockOutModal" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">
                    <i class="fas fa-arrow-up me-2"></i>耗材出库
                </h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
            </div>
            <form method="post" action="{% url 'assets:consumable_detail' consumable.pk %}">
                {% csrf_token %}
                <input type="hidden" name="action" value="stock_out">
                <div class="modal-body">
                    <div class="mb-3">
                        <label class="form-label">出库数量</label>
                        <input type="number" class="form-control" name="quantity" step="0.01" min="0.01"
                            max="{{ consumable.quantity }}" required>
                        <div class="form-text">单位: {{ consumable.unit }}，当前库存: {{ consumable.quantity }}</div>
                    </div>
                    <div class="mb-3">
                        <label class="form-label">出库说明</label>
                        <textarea class="form-control" name="description" rows="3"
                            placeholder="请输入出库原因或说明..."></textarea>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                    <button type="submit" class="btn btn-warning">
                        <i class="fas fa-check me-1"></i>确认出库
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>

<script>
    function exportRecords() {
        alert('导出功能开发中...');
    }

    function printLabel() {
        alert('打印标签功能开发中...');
    }

    function showLogDetail(logId) {
        alert('查看记录详情功能开发中... ID: ' + logId);
    }

    function deleteLog(logId) {
        if (confirm('确定要删除这条记录吗？')) {
            alert('删除记录功能开发中... ID: ' + logId);
        }
    }
</script>

{% endblock %}